package com.qf.web;

import com.qf.pojo.Admin;
import com.qf.service.AdminService;
import com.qf.service.impl.AdminServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

public class LoginServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        AdminService adminService=new AdminServiceImpl();
        String name = req.getParameter("username");
        String pass = req.getParameter("password");
        System.out.println(name);
        System.out.println(pass);
        //响应客户端
        //PrintWriter writer = resp.getWriter();

        List<Admin> a = adminService.findAdmian(name, pass);
        if(a!=null){
            System.out.println("登录成功");
          resp.sendRedirect("/success.jsp");
        }else{
        System.out.println("登陆失败");
        resp.sendRedirect("/fail.jsp");
        }
    }
//
//    @Override
//    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        super.doPost(req, resp);
//    }
}
